<template>
<span :class="wrapper_name">

  <button v-if="col.btns.ADDPRO" class="ui button primary mini" @click.stop.prevent="add_pro(col.val)" title="添加商品">
    {{col.btns.ADDPRO}}
  </button>
  <!-- <button v-if="col.btns.ADDTR" class="ui button primary mini" @click.stop.prevent="add_tr(col.val)" title="添加场景">
    {{col.btns.ADDTR}}
  </button> -->
</span>
</template>
<script type="text/ecmascript-6">
import tool from 'src/util/tool';
import util from '_util/index';
import logic from '_logic'


export default {
    data() {
        return {}
    },
    methods: {
        add_pro(id) {
            //TODO 添加商品
            let _this = this;
			util.store.push(_this, 'set_in_modal','in_modal',false,true,'global');
            this.$store.state.global.eventVue.$emit('showPopCom', {
                _this: this,
                id: id,
                data: {
                    fn: {
                        sure: function(data) {
                            let param = {
                                product_ids: JSON.parse(data.id).toString(),
								warehouse_id:id
                            };
							util.http.SR(_this, '/index/Product/addWarehouseProduct', param, '添加成功', (rs) => {
			                    logic.list.refreshListData(_this);
			                });
                        }
                    },
                    field: {
                        bindModel: 105,
                        bind_type: 1,
                        title: '添加商品',
                        name: 'id',
                        bind_name_field: 'name',
						search_field:'name'
                    }
                },
				hide_in_model:true,
                name: 'Jbind'
            });
        },
        add_tr(id) {
            /**
             * 触发mypop.vue下showPopCom监听事件 显示spDelivery模板 添加tr场景
             * */
            let _this = this;
            this.$store.state.global.eventVue.$emit('showPopCom', {
                _this: this,
                id: _this.$route.query.product_id,
                data: {
                    fn: {
                        sure: function(data) {
							let param = {
                                hotel_id: JSON.parse(data.id).join('|'),
								warehouse_id:id
                            };
							util.http.SR(_this, '/index/Product/addWarehouseUse', param, '添加成功', (rs) => {
			                    logic.list.refreshListData(_this);
			                });
                        }
                    },
                    field: {
                        bindModel: 1,
                        bind_type: 1,
                        title: '添加场景',
                        name: 'id',
                        bind_name_field: 'name',
                    }
                },
                name: 'Jbind'
            });
        }
    },
    computed: {
        ctl() {
            return this.$route.query.ctl;
        },
        is_admin() {
            return util.is_admin(this);
        },
    },
    watch: {},

    props: ['col', '_id', 'detail_info', 'wrapper_name'],
    created() {},
}
</script>
<style rel="stylesheet/less" lang="less">
</style>
